package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	PlanEventNew          = "mes.PlanNew"
	PlanEventBeforeCreate = "mes.PlanBeforeCreate"
	PlanEventBeforeUpdate = "mes.PlanBeforeUpdate"
	PlanEventBeforeSave   = "mes.PlanBeforeCreate mes.PlanBeforeUpdate"
	PlanEventAfterCreate  = "mes.PlanAfterCreate"
	PlanEventAfterUpdate  = "mes.PlanAfterUpdate"
	PlanEventAfterSave    = "mes.PlanAfterCreate mes.PlanAfterUpdate"
	PlanEventDelete       = "mes.PlanDelete"

	PlanAccessControlEvent = "mes.PlanAccessControl"
)

func GetPlanConfig() *mgo.DocConfig {
	return Plan_Config
}

var Plan_Config *mgo.DocConfig

func init() {
	Plan_Config = NewPlanConfig()
}

func NewPlanConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.Plan",
		Fields: []string{
			"sn", "product", "numNeed", "numDone", "template", "printCount",
		},
		RelationFields: []string{
			"template",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"template": {
				Config:     GetProcessTemplateConfig,
				DocName:    "ProcessTemplate",
				JoinType:   "O",
				KeyInside:  "templateId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
